import { BizscenariosAgent, IBackgroundList, IWatermarkImageList } from '../interface';
import Client from '../libs/Client';
import BackGroundListDao from './BackGroundListDao';
import WaterMarkDao from './WaterMarkDao';

class AgentDao {
	public static background: BackGroundListDao = new BackGroundListDao();
	public static waterMark: WaterMarkDao = new WaterMarkDao();
	public static sessionClient: Map<string, Client> = new Map();
	public static agentsList: BizscenariosAgent[] = [];

	public getBackgroundList() {
		return AgentDao.background.findAllBackgroundList();
	}

	public setBackgroundList(list: IBackgroundList[]) {
		return AgentDao.background.setBackgroundList(list);
	}

	public getBackgroundId() {
		return AgentDao.background.getBackgroundId();
	}

	public setBackgroundId(id: number) {
		return AgentDao.background.setBackgroundId(id);
	}

	public getWaterMarkList() {
		return AgentDao.waterMark.findAllWaterMarkList();
	}

	public setWaterMarkList(list: IWatermarkImageList[]) {
		return AgentDao.waterMark.setWaterMarkList(list);
	}

	public getWaterMarkId() {
		return AgentDao.waterMark.getWaterMarkId();
	}

	public setWaterMarkId(id: number) {
		AgentDao.waterMark.setWaterMarkId(id);
	}

	public static findSessionClientWithLabel(label: string) {
		return AgentDao.sessionClient.get(label);
	}

	public static setSessionClient(client: Client) {
		AgentDao.sessionClient.set(client.streamInfo.streamLabel, client);
		console.log('sessionClient:', AgentDao.sessionClient);
	}

	public static clearSessionClient() {
		AgentDao.sessionClient.clear();

		console.log('AgentDao.sessionClient', AgentDao.sessionClient);
	}

	public static removeSessionClientWithLabel(label: string) {
		if (AgentDao.findSessionClientWithLabel(label)) {
			AgentDao.sessionClient.delete(label);
			console.log('AgentDao.removeSessionClientWithLabel', AgentDao.sessionClient);
		}
	}

	public static setBizscenariosAgents(list: BizscenariosAgent[]) {
		AgentDao.agentsList = list;
	}

	public static getBizscenariosAgents() {
		return AgentDao.agentsList;
	}
}

export default AgentDao;
